package com.healthy_software.controller;


import com.healthy_software.dto.SetGoalRequestDTO;
import com.healthy_software.result.Result;
import com.healthy_software.service.GoalService;
import com.healthy_software.utils.UserIdHolder;
import com.healthy_software.vo.GoalVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/goals")
public class GoalController {
    @Resource
    private GoalService goalService;

    @GetMapping
    public Result<GoalVO> getGoal(){
        Long userId = UserIdHolder.getCurrentId();
        return goalService.getGoal(userId);
    }

    @PostMapping("/set")
    public Result<Integer> setGoal(@RequestBody SetGoalRequestDTO setGoalRequestDTO){
        Long userId = UserIdHolder.getCurrentId();
        log.info(String.valueOf(userId));
        return goalService.setGoal(userId, setGoalRequestDTO);
    }


}
